package com.pan.show.factory.impl;

import com.pan.show.record.Record;
import com.pan.show.factory.RecordFactory;
import com.pan.utils.ApplicationConfig;

public class SingleRecordFactory implements RecordFactory {

    private Record singleRecord = null;

    @Override
    public Record getRecord() {
        if (singleRecord != null ) {
            return singleRecord;
        }
        String className = ApplicationConfig.INSTANCE.getRecordClassName();
        Record record = null;
        try {
            Class clazz = Class.forName(className);
            record = (Record) clazz.getConstructor().newInstance();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        singleRecord = record;
        return singleRecord;
    }
}
